{extend name="user_base" /} {block name="seo"}
{/block}
{block name="css"}
{/block}
{block name="body"}
<div class="page page-current us-w" id="login">
    <!-- 这里是页面内容区 -->
    <div class="content">
        <header id="header" class="clearfix theader baise">
            <a href="/" class="back iconfont icon-fanhui"></a>
            <h3 class="titlea">登录账号</h3>
        </header>
        <form action="" method="post" id="loginForm" onsubmit="return false">
            <div class="inline clearfix">
                <i class="iconfont icon-zhanghao"></i>
                <input type="text" name="username" placeholder="手机/邮箱/用户名"/>
            </div>
            <div class="inline clearfix">
                <i class="iconfont icon-mima"></i>
                <input type="password" name="password" placeholder="请输入您的密码"/>
            </div>
            <div class="inline layui-clear code" hidden>
                <i class="iconfont icon-yanzhengma"></i>
                <input type="text" placeholder="右侧验证码" name="verify_code" autocomplete="off" maxlength="4"
                       style="width:calc(100% - 6rem - 3rem);" >
                <img src="{:url('index/page/captcha')}?'+Math.random();" title="点击可刷新图形码" onclick="this.src='{:url(\'index/page/captcha\')}?_='+Math.random()"  class="imgcode" />
            </div>
            <div class="loo clearfix">
                {if $site_config.qqlogin_status eq 1}
                <div class="ks">
                    <a href="/user/qqlogin.html" class="external" ><img src="//static.115z.com/img/qq.png"></a>
                </div>
                {/if}
                <div class="zc">
                    <a href="/user/register.html" class="zczh">注册账号</a>
                    <a href="/user/forgetpass.html">找回密码</a>
                </div>
            </div>
            <button class="btn">立即登录</button>
        </form>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">

    $("#loginForm").submit(function (e) {

        var vf = $(this).verify({
            // username: function (v, item) {
            //     if (!isPhone(v) && !isEmail(v)) {
            //         return "请使用邮箱或手机号登陆";
            //     }
            // },
            password: function (v, item) {
                if (!v || v.length < 6 || v.length > 18) {
                    return "请输入6 ~ 18 位的密码";
                }
            },
            verify_code: function (v, item) {
                if (!$(".code").isHide() && ( !v || v.length !==4)) {
                    return "请输正确的验证码";
                }
            }

        });
        if (vf) {
            var data = $(this).field();
            request({
                url: config.api.login, data: data,
                done: function (result) {
                    if (result.data['vf_code']) {
                        $(".code").show(100).find(".imgcode").trigger('click');
                    }
                    setTimeout(function () {
                        document.referrer = "/index.html";
                    },20)
                }
            });
        }
        return false;
    });
</script>
{/block}
